/* ========== 变量 & 重置 ========== */
:root {
  --bg-gradient-start: #ffe4e1;
  --bg-gradient-end:   #fffacd;
  --glass-bg:          rgba(255,255,255,0.75);
  --glass-border:      rgba(255,255,255,0.85);
  --accent-color:      #ffb6c1;
  --font:              'Open Sans', sans-serif;
  --text-primary:      #333;
  --text-secondary:    #555;
  --radius:            1rem;
  --gap:               1rem;
  --ease:              cubic-bezier(.17,.67,.83,.67);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ========== 基础布局 ========== */
body {
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-primary);
  position: relative;
}

.background {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ========== 聊天面板 ========== */
.chat-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* — 顶部栏 — */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap) 1.5rem;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(6px);
}

.chat-header h2 {
  font-weight: 600;
  font-size: 1.2rem;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.icon-btn:hover {
  color: var(--text-primary);
}

/* — 聊天列表 — */
.chat-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 var(--gap);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-list::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 3px;
}

/* Loader */
.loader {
  width: 40px;
  height: 40px;
  margin: 2rem auto;
  border: 4px solid rgba(0,0,0,0.1);
  border-top: 4px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 消息项 ========== */
.chat-item {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  opacity: 0;
}

.chat-item.other {
  align-self: flex-start;
  flex-direction: row;
}

.chat-item.self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* — 气泡 — */
.msg-bubble {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.chat-item.self .msg-bubble {
  background: rgba(255,255,255,0.9);
}

/* — 文本 & 时间 — */
.msg-content {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.msg-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-align: right;
}

/* — 头像 — */
.msg-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

.chat-item.other .msg-avatar {
  margin-right: 1rem;
}

.chat-item.self .msg-avatar {
  margin-left: 1rem;
}

/* ========== 输入区 ========== */
.chat-input-area {
  display: flex;
  flex-direction: column;
  padding: var(--gap);
  background: rgba(255, 255, 255, 0.85);  /* 增加背景不透明度 */
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);  /* 添加上阴影 */
}

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* 表情按钮 */
#emoji-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(0, 0, 0, 0.1);
  color: var(--text-secondary);
  font-size: 1.2rem;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
}

#emoji-btn:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
  transform: scale(1.05);
}

/* 消息输入框 */
#messageInput {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid rgba(0, 0, 0, 0.1);  /* 更明显的边框 */
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);  /* 更不透明的背景 */
  color: var(--text-primary);  /* 使用主文本颜色 */
  font-size: 1rem;
  transition: all 0.3s;
}

#messageInput:focus {
  outline: none;
  border-color: var(--accent-color);  /* 使用主题色 */
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#messageInput::placeholder {
  color: rgba(0, 0, 0, 0.4);  /* 更深的占位符颜色 */
}

/* 发送按钮 */
#send-btn {
  background: var(--accent-color);  /* 使用主题色 */
  border: none;
  color: white;
  padding: 12px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

#send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 182, 193, 0.4);  /* 使用主题色阴影 */
  background: #ff9eb5;  /* 略微亮色 */
}

/* Emoji 选择器样式 */
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.emoji-item {
  cursor: pointer;
  padding: 5px;
  text-align: center;
  font-size: 1.2em;
  transition: transform 0.2s;
  user-select: none;
}

.emoji-item:hover {
  transform: scale(1.2);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* 滚动条美化 */
.emoji-picker::-webkit-scrollbar {
  width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-picker::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  overflow-y: auto; /* 允许滚动 */
  padding: 20px 0; /* 上下留白 */
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 480px;
  margin: 20px auto;
  background: rgba(255, 255, 255, 0.95); /* 更亮的背景 */
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9); /* 更亮的头部背景 */
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h3 {
  color: var(--text-primary); /* 使用主文本色 */
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  padding: 0;
  margin: 0;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.close-btn:active {
  background: rgba(0, 0, 0, 0.1);
  transform: rotate(90deg) scale(0.95);
}

.close-btn i {
  font-size: 20px;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.avatar-section {
  text-align: center;
  margin-bottom: 24px;
}

.friend-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
  transition: transform 0.3s;
}

.friend-avatar:hover {
  transform: scale(1.05);
}

.friend-nickname {
  font-size: 1.4rem;
  color: var(--text-primary);
  margin: 0;
  font-weight: 600;
}

.info-card, .bio-card, .remark-card {
  background: rgba(255, 255, 255, 0.9); /* 更亮的卡片背景 */
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-item:last-child {
  border-bottom: none;
}

.info-item i {
  font-size: 1.2rem;
  color: var(--accent-color); /* 使用主题色 */
  width: 24px;
}

.info-content {
  flex: 1;
}

.info-content label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary); /* 次要文本色 */
  margin-bottom: 4px;
}

.info-content span {
  color: var(--text-primary); /* 主文本色 */
  font-weight: 400;
}

.bio-header, .remark-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.bio-content {
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  font-style: italic;
}

.remark-input-group {
  display: flex;
  gap: 8px;
}

#remarkInput {
  flex: 1;
  background: white; /* 纯白背景 */
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
}

.btn-save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
}

.btn-save:hover {
  background: #ff9eb5; /* 略微亮色 */
  transform: translateY(-1px);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式调整 */
@media (max-width: 480px) {
  .modal-content {
    margin: 20px auto;
  }
  
  .friend-avatar {
    width: 80px;
    height: 80px;
  }
  
  .friend-nickname {
    font-size: 1.2rem;
  }
}
